using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManager : MonoBehaviour
{
    public static GameManager Instance { get; private set; }

    public PrePareUI prePareUI;
    public CardListUI cardListUI;
    public bool isGameEnd=false ;
    public FailUI failUI;
    public WinUI winUI;
    private void Awake()
    {
        Instance = this;
    }

    // Start is called before the first frame update
    void Start()
    {
        GameStart();
    }
    // Update is called once per frame
    void Update()
    {

    }
    void GameStart()
    {
        Vector3 currentPosition = Camera.main.transform.position;
        Camera.main.transform.DOPath(new Vector3[] {currentPosition,
            new Vector3(5,0,-10),currentPosition }, 4f, PathType.Linear).OnComplete(OnCamerMoveComplete);
    }
    public void GameEndFail()
    {
        if (isGameEnd) return;
        isGameEnd = true;
        failUI.Show();
        ZombieManager.Instance.Pause();
        cardListUI.DisableCardList();
        SunManager.Instance.StopProduce();
        AudioManager.Instance.PlayClip(Config.lose_music);
    }
    public void GameEndSuccess()
    {
        if (isGameEnd) return;
        isGameEnd = true;
        winUI.Show();
        cardListUI.DisableCardList();
        SunManager.Instance.StopProduce();
        AudioManager.Instance.PlayClip(Config.win_music);
    }
         
    void OnCamerMoveComplete()
    {
        prePareUI.Show(OnPrepareUIComplete);

    }
    void OnPrepareUIComplete()
    {
        SunManager.Instance.StartProduce();
        ZombieManager.Instance.StartSpawn();
        cardListUI.ShowCardList();
        AudioManager.Instance.PlayBgm(Config.bgm1);

    }
}
